package com.tencent.wxcloudrun.controller;

import com.tencent.wxcloudrun.model.CateGoods;
import com.tencent.wxcloudrun.response.R;
import com.tencent.wxcloudrun.service.CateGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: CateGoodsController
 * Package: com.tencent.wxcloudrun.controller
 * Description:
 *
 * @Date: 2023/2/9 8:15 AM
 * @Author: wht
 */

@Slf4j
@RestController
//@RestController = @Controller + @ResponseBody
@RequestMapping("/admin")
public class CateGoodsController {
    @Autowired
    CateGoodsService cateGoodsService;

    @PutMapping("/addOneCateGoods")
    public <T> R<T> addOneCateGoods(@RequestBody CateGoods cateGoods) {
        cateGoodsService.addOneCateGoods(cateGoods);
        return R.successMsg("添加成功！");
    }

    @PatchMapping("/updateOneCateGoodsById")
    public <T> R<T> updateOneCateGoodsById(@RequestBody CateGoods cateGoods) {
        cateGoodsService.updateOneCateGoodsById(cateGoods);
        return R.successMsg("修改成功！");
    }

    @PostMapping("/getCateGoodsList")
    public <T> R<T> getCateGoodsList(@RequestBody CateGoods cateGoods) {
        List<CateGoods> cateList = cateGoodsService.getCateGoodsList(cateGoods);
        return R.successData(cateList);
    }
}
